cmake_minimum_required(VERSION 3.10)
project(Cpp)

execute_process(COMMAND find ${CMAKE_CURRENT_SOURCE_DIR} -maxdepth 1 -mindepth 1 -type d 
                COMMAND xargs -n 1 basename 
                COMMAND xargs
                WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                OUTPUT_VARIABLE SUB_DIR)
string(REPLACE "\n" " " SUB_DIR  ${SUB_DIR})

set(DIR_LIST ${SUB_DIR})
separate_arguments(DIR_LIST)
list(FILTER DIR_LIST EXCLUDE REGEX "build")
list(FILTER DIR_LIST EXCLUDE REGEX ".vscode")
list(FILTER DIR_LIST EXCLUDE REGEX ".idea")
message("DIR_LIST=${DIR_LIST}")

foreach(SUB  ${DIR_LIST})
    message("SUB=${SUB}")
    add_subdirectory(${SUB})
endforeach()